extends Base1
@onready var player:CharacterBody2D=$"../.."
@onready var animate:AnimatedSprite2D=$"../../AnimatedSprite2D"


var attack:bool=false
func enter():
	pass

func do():
	if Input.is_action_just_released("parasite"):
		get_parent().change_state(3)
		return
	elif Input.is_action_just_released("attack"):
		get_parent().change_state(2)
		return
	var direction := Input.get_vector("左", "右", "上", "下")
	direction = direction.normalized()  # 确保方向向量长度为1，保持速度一致

	if !direction:
		get_parent().change_state(0)
	elif(direction != Vector2.ZERO):
		# 根据方向设置动画
		if direction.x < 0:
			animate.play("left")
		elif direction.x > 0:
			animate.play("right")
		if direction.y < 0:
			animate.play("up")
		elif direction.y > 0:
			animate.play("down")
	player.move_and_slide()
	pass
